package com.xb.p5_uidemo;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Typeface;
import android.os.Bundle;
import android.text.Spannable;
import android.text.Spanned;
import android.text.style.StyleSpan;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        TextView textView=findViewById(R.id.tv_info);
        Spannable spannable=(Spannable)textView.getText();

        //样式
        StyleSpan blodSpan=new StyleSpan(Typeface.BOLD);

        spannable.setSpan(blodSpan,0,4, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    }
}
